import { defineStore } from 'pinia'

export const useUserStore = defineStore('userInfo', {
  state: () => ({ 
    userInfo: {},
    token: '',
    phone:'', //用户手机号
    password:'', //用户密码
    messages:[], //AI聊天信息记录
    cozeToken:{} //扣子平台token保存
 }),
  actions: {
    setUserInfo(data) {
      this.userInfo = data
    },
    getUserInfo() {
      return this.userInfo
    },
    setToken(value) {
      this.token = value
    },
    getToken() {
      return this.token
    },
    setPhone(value) {
      this.phone = value
    },
    getPhone() {
      return this.phone
    },
    setPassword(value) {
      this.password = value
    },
    getPassword() {
      return this.password
    },
    setMessages(data){
      this.messages = data
    },
    getMessages(){
      return this.messages
    },
    setCozeToken(data){
      this.cozeToken = data
    },
    getCozeToken(){
      return this.cozeToken
    }
  },
  persist: {
    enabled: true,
    strategies: [
      { storage: localStorage, paths: ['userInfo'] }
    ]
  }
})